<template>
  <div class="">
    <div>
      <van-search
        v-model="dataquery.name"
        show-action
        placeholder="请输入搜索关键词"
        @search="onSearch"
        @cancel="onCancel"
        input-align="center"
      />
    </div>


    <div class="infoview">
      <p @click="clickcpmpany(item)" v-for="(item,index) in datalist" :key="index">{{item}}</p>
    </div>
  </div>
</template>

<script>
import { Dialog } from 'vant';
export default {
  data(){
    return{
      datalist:null,
      dataquery:{
        name:null
      }
    }
  },
  created(){
    this.getdata()
  },
  methods:{
    getdata(){
      let dataa = {
        name:null
      }
      if (this.dataquery.name !== null) {
        dataa.name = this.dataquery.name
      }else{
        dataa=''
      }
      this.$Api
        .get("/api/corp/getQyName",dataa)
        .then(res => {
          if (res.data.code == 200) {
            this.datalist = res.data.data
          } else {

            // this.$dialog.toast({
            //   mes: res.data.message,
            //   timeout: 1500
            // });
          }
        })
        .catch(err => {});
    },
    clickcpmpany(e){
      Dialog.confirm({
  title: '确认',
  message: `是否选择${e}?`,
})
  .then(() => {
    // on confirm
    this.$store.commit('setchengeComponey',e)
    this.$router.back(-1)
  })
  .catch(() => {
    // on cancel
  });
    },
    onSearch() {
      this.getdata();
    },
    onCancel() {
      this.dataquery.name = null;
      this.getdata();
    }
  }
}
</script>

<style lang="css" scoped>
.infoview p{
  padding: 1rem;
  border-bottom: 0.1rem solid rgba(0, 0, 0, 0.1);
}
</style>
